﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Engine.Classes {

	/**
	 * CollisionMap的一个格子
	 * 
	 */
    public class CollisionCell {

        public var x:int;
        public var y:int;
        public var windows:Array;
        public var walls:Array;
        public var items:Array;
        public var isPathable:Boolean;

        public function CollisionCell(_arg1:int, _arg2:int){
            this.windows = [];
            this.walls = [[], [], [], []];	// 四个方向的其他物品
            this.items = [];
            super();
            this.x = _arg1;
            this.y = _arg2;
            this.isPathable = false;
        }
        public function dispose():void{
            this.windows = null;
            this.walls = null;
            this.items = null;
        }
        public function setWall(_arg1:int, _arg2:WorldObject):void{
            var _local3:Array = (this.walls[_arg1] as Array);
            if (_local3.indexOf(_arg2) == -1){
                _local3.push(_arg2);
            };
        }
        public function getWalls(_arg1:int):Array{
            return (this.walls[_arg1]);
        }
        public function addObject(_arg1:WorldObject):void{
            this.items.push(_arg1);
        }
		
		
		/**
		 * 把这个object从Walls和Items删除
		 */
        public function removeObject(_arg1:WorldObject):void{
            var _local4:Array;
            var _local2:int = this.items.indexOf(_arg1);
            if (_local2 != -1){
                this.items.splice(_local2, 1);
            };
            var _local3:int;
            while (_local3 < 4) {
                _local4 = this.walls[_local3];
                _local2 = _local4.indexOf(_arg1);
                if (_local2 != -1){
                    _local4.splice(_local2, 1);
                };
                _local3++;
            };
        }

    }
}//package Engine.Classes 
